package com.luweijie.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.luweijie.entity.Mountings;
import com.luweijie.entity.vo.Result;
import com.luweijie.service.CalculatorBackgroundService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * <p>
 * 计算器后台
 * </p>
 *
 * @author luweijie
 * @since 2020-06-03
 */
@RestController
@RequestMapping("/activity")
@Slf4j
public class CalculatorBackgroundController {

    @Autowired
    CalculatorBackgroundService calculatorBackgroundService;

    @PostMapping("/inster/mounting")
    public Result insters( @RequestBody Mountings mountings){
          log.info("新增的配件为："+mountings);
        System.out.println("ShzwActivityPo = " + mountings);
        return Result.success( calculatorBackgroundService.add(mountings));
    }

    @GetMapping("/get/query")
    public Result Query(Page page){
        IPage<Mountings> query = calculatorBackgroundService.query(page);
        return Result.success(query);
    }

    @PutMapping(value = "/{id}")
    public Result update( @PathVariable int id,@RequestBody Mountings mountings){
        log.info("更新的配件为："+mountings);
        mountings.setId(id);
        return Result.success(calculatorBackgroundService.updata(mountings));
    }


}
